<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Upload material</title>
<script type="text/javascript">
	function deleteFile(course_id,file_id){
		if(confirm("Are you sure you want to delete this flle?")){
			window.location="delete_material.html?course_id="+course_id+"&file_id="+file_id;
		}	
	}

</script>
</head>
<body>
<center>
	<table border="0" cellpadding="0" cellspacing="0" width="70%" class="newsTitle">
		<tr><td colspan="3" height="10"> </td></tr>	
		<tr align="center"><td colspan="3" height="30" style="font-size:14px;"><u>តារាងឯកសារណែនាំ</u></td></tr>
		<tr><td colspan="3" height="10"> </td></tr>
		<tr><td colspan="3" height="10" align="center"><c:out value="${Course[0].COURSE_NAME}"></c:out></td></tr>
		<tr><td colspan="3" height="10"> </td></tr>
	</table>
	<form:form modelAttribute="uploadItem" name="frm" method="post" enctype="multipart/form-data" onsubmit="return Validate();">
	<table border="0" cellpadding="0" cellspacing="0" width="70%" class="newsTitle">	
		<tr>
			<td align="right" width="150">ជ្រើសរើសឯកសារ :</td>
			<td>
			&nbsp;<form:input path="fileData" id="txtfile" type="file" />
			</td>
		</tr>
		<tr><td colspan="2" height="5"> </td></tr>
		<tr>
			<td align="right">ចំណងជើងឯកសារ :</td>
			<td>
			&nbsp;<input type="text" id="txttitle" name="txttitle" maxlength="250" style="width: 300px;" class="box"/>
			</td>
		</tr>
		<tr><td colspan="2" height="5"> </td></tr>
		<tr>
			<td align="right">ប្រភេទឯកសារ :</td>
			<td>
			&nbsp;<select name="txttype" id="txttype" style="width: 100px;">
				<c:forEach var="x" begin="0" end="${fn:length(MaterialType)-1}" step="1" varStatus ="status">
					<option value="${MaterialType[x].TYPE_ID}"><c:out value="${MaterialType[x].TYPE_DESC}"></c:out></option>
				</c:forEach>
			</select>
			</td>
		</tr>
		<tr><td colspan="2" height="5"> </td></tr>
		<tr>
			<td align="right">បរិយាយ :</td>
			<td>
			&nbsp;<textarea name="txtdesc" id="txtdesc" rows="10" style="font-family: verdana, sans-serif;font-size:11px;width: 300px;"></textarea>
			</td>
		</tr>
		<tr><td colspan="2" height="5"> </td></tr>
		<tr>
			<td align="right">រៀបចំដោយ :</td>
			<td>
			&nbsp;<input type="text" id="txtpreparedby" name="txtpreparedby" maxlength="250" style="width: 300px;" class="box"/>
			</td>
		</tr>
		<tr><td colspan="2" height="5"> </td></tr>
		<tr>
			<td colspan="2" align="center">  
			<input type="submit" value="Upload" class="input_button" >
			</td>
		</tr>
	</table>
	</form:form>
	<table border="0" cellpadding="0" cellspacing="0" width="70%" class="newsTitle">	
		<tr><td colspan="3" height="30" style="font-size:13px;"><u>ឯកសារវីដេអូ</u></td></tr>
		<tr class="myuploadheader" align="center">
			<td width="15%" height="25">លេខ</td>	
			<td width="60%">ឈ្មោះឯកសារ</td>	
			<td width="25%">រូបភាព |លុបចោល</td>
		</tr>
		<%
			String bgcolor1="#EEE";
		%>
		<c:if test="${fn:length(VideoList)>0}">
			<c:forEach var="x" begin="0" end="${fn:length(VideoList)-1}" step="1" varStatus ="status">
				<%
					bgcolor1=(bgcolor1=="#EEE")?"#FFF":"#EEE";
				%>
						<tr bgcolor="<%=bgcolor1%>" align="center">
							<td align="center" style="border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;"><c:out value="${x+1}"/></td>
							<td align="center" height="40" valign="middle" style="border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;padding-right: 4px; padding-left: 4px;"><c:out value="${VideoList[x].FILE_TITLE }"></c:out></td>
							<td style="border:solid 1px #DDD; border-top:solid 0px #DDD;"><a href="course_image.html?file_id=${VideoList[x].FILE_ID}&course_id=${VideoList[x].COURSE_ID}">រូបភាព</a> | <label style="cursor: pointer; color:#0066FF;" onclick="deleteFile(${VideoList[x].COURSE_ID},${VideoList[x].FILE_ID})">លុបចោល</label></td>
						</tr>
			</c:forEach>
		</c:if>
		<tr><td colspan="3">&nbsp;</td></tr>
	</table>
	
	<table border="0" cellpadding="0" cellspacing="0" width="70%" class="newsTitle">
		<tr><td colspan="3" height="30" style="font-size:13px;"><u>ឯកសារជាអត្ថបទ</u></td></tr>
		<tr class="myuploadheader" align="center">
			<td width="15%" height="25">លេខ</td>	
			<td width="60%">ឈ្មោះឯកសារ</td>	
			<td width="25%">លុបចោល</td>
		</tr>
		<%
			String bgcolor2="#EEE";
		%>
		<c:if test="${fn:length(TextList)>0}">
			<c:forEach var="x" begin="0" end="${fn:length(TextList)-1}" step="1" varStatus ="status">
				<%
				bgcolor2=(bgcolor2=="#EEE")?"#FFF":"#EEE";
				%>
						<tr bgcolor="<%=bgcolor2%>" align="center">
							<td align="center" style="border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;"><c:out value="${x+1}"/></td>
							<td align="center" height="40" valign="middle" style="border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;padding-right: 4px; padding-left: 4px;"><c:out value="${TextList[x].FILE_TITLE }"></c:out></td>
							<td style="border:solid 1px #DDD; border-top:solid 0px #DDD;"><label style="cursor: pointer; color:#0066FF;" onclick="deleteFile(${TextList[x].COURSE_ID},${TextList[x].FILE_ID})">លុបចោល</label></td>
						</tr>
			</c:forEach>
		</c:if>
		<tr><td colspan="3">&nbsp;</td></tr>
	</table>
	
	<table border="0" cellpadding="0" cellspacing="0" width="70%" class="newsTitle">
		<tr><td colspan="3" height="30" style="font-size:13px;"><u>ឯកសារជាសំលេង</u></td></tr>
		<tr class="myuploadheader" align="center">
			<td width="15%" height="25">លេខ</td>	
			<td width="60%">ឈ្មោះឯកសារ</td>	
			<td width="25%">លុបចោល</td>
		</tr>
		<%
			String bgcolor3="#EEE";
		%>
		<c:if test="${fn:length(AudioList)>0}">
			<c:forEach var="x" begin="0" end="${fn:length(AudioList)-1}" step="1" varStatus ="status">
				<%
				bgcolor3=(bgcolor3=="#EEE")?"#FFF":"#EEE";
				%>
						<tr bgcolor="<%=bgcolor2%>" align="center">
							<td align="center" style="border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;"><c:out value="${x+1}"/></td>
							<td align="center" height="40" valign="middle" style="border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;padding-right: 4px; padding-left: 4px;"><c:out value="${AudioList[x].FILE_TITLE }"></c:out></td>
							<td style="border:solid 1px #DDD; border-top:solid 0px #DDD;"><label style="cursor: pointer; color:#0066FF;" onclick="deleteFile(${AudioList[x].COURSE_ID},${AudioList[x].FILE_ID})">លុបចោល</label></td>
						</tr>
			</c:forEach>
		</c:if>
		<tr><td colspan="3">&nbsp;</td></tr>
	</table>
	
	<table border="0" cellpadding="0" cellspacing="0" width="70%" class="newsTitle">
		<tr><td colspan="3" height="30" style="font-size:13px;"><u>ឯកសារប្រភេទផ្សេងទៀត</u></td></tr>
		<tr class="myuploadheader" align="center">
			<td width="15%" height="25">លេខ</td>	
			<td width="60%">ឈ្មោះឯកសារ</td>	
			<td width="25%">លុបចោល</td>
		</tr>
		<%
			String bgcolor4="#EEE";
		%>
		<c:if test="${fn:length(OtherList)>0}">
			<c:forEach var="x" begin="0" end="${fn:length(OtherList)-1}" step="1" varStatus ="status">
				<%
				bgcolor4=(bgcolor4=="#EEE")?"#FFF":"#EEE";
				%>
						<tr bgcolor="<%=bgcolor4%>" align="center">
							<td align="center" style="border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;"><c:out value="${x+1}"/></td>
							<td align="center" height="40" valign="middle" style="border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;padding-right: 4px; padding-left: 4px;"><c:out value="${OtherList[x].FILE_TITLE }"></c:out></td>
							<td style="border:solid 1px #DDD; border-top:solid 0px #DDD;"><label style="cursor: pointer; color:#0066FF;" onclick="deleteFile(${OtherList[x].COURSE_ID},${OtherList[x].FILE_ID})">លុបចោល</label></td>
						</tr>
			</c:forEach>
		</c:if>
		<tr><td colspan="3">&nbsp;</td></tr>
		<tr>
			<td colspan="3" align="center">
				<input type="button" class="input_button" value="រួចរាល់ "  onclick="window.location='course_list.html'">
			</td>
		</tr>
	</table>
</center>
</body>
</html>